package com.huage_09;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class MapToJson {
    public static void main(String[] args) throws JsonProcessingException {
        Map<String,Object> userMap = new HashMap<String,Object>();
        userMap.put("cardID","12345");
        userMap.put("username","张三");
        userMap.put("account",230);
        userMap.put("lastTime",new Date());

        ObjectMapper obj = new ObjectMapper();
        String json = obj.writeValueAsString(userMap);
        System.out.println(json);
    }
}
